package com.xiaomaoguai.eventbus.exercise;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import com.google.common.eventbus.EventBus;

/**
 * @Description :
 * @FileName: EventBusChat.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年6月18日 下午4:59:26
 * @Version:V1.00
 */
public class EventBusChat {

	public static void main(String[] args) {
		EventBus channel = new EventBus();
		ServerSocket socket;
		try {
			socket = new ServerSocket(4444);
			while (true) {
				Socket connection = socket.accept();
				UserThread newUser = new UserThread(connection, channel);
				channel.register(newUser);
				newUser.start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
